package com.lyf.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lyf.dao.UserDao;
import com.lyf.pojo.User;

@Service
@Transactional
public class UserService {

	@Autowired
	private UserDao dao;
	
	public User login(User user){
		User u = dao.findByUnique("username", user.getUsername());
		if(u != null && u.getPassword().equals(user.getPassword())){
			return u;
		}
		return null;
	}
	
	
	@Transactional(readOnly=true)
	public List<User> findAll(){
		return dao.findAllByOrder("desc", "createtime");
	}


	public User findById(String id) {
		return dao.get(id);
	}
	
	
}
